package name.yzhu.httpserver;

import java.util.Map;

import com.google.common.collect.Maps;

/**
 * 
 */

/**
 * @author yhzhu
 *
 */
public enum HttpRequestType {
	Get(1, "GET"),
	Post(2, "POST"),
	Put(3, "PUT"),
	Delete(4, "DELETE"),
	Unknown(0, "");

	private int value = 0;
	private String name = "";

	private HttpRequestType(int v, String name) {
		this.value  = v;
		this.name  = name;
	}
	
	public int getValue(){
		return value;
	}
	
	public String getName(){
		return name;
	}
	
	static Map<String, HttpRequestType> mapName = Maps.newHashMap();
	static Map<Integer, HttpRequestType> mapValue = Maps.newHashMap();
	static {
		for (HttpRequestType rt : HttpRequestType.values()){
			mapName.put(rt.getName(), rt);
			mapValue.put(rt.getValue(), rt);
		}
	}
	
	public static HttpRequestType byValue(int value){
		return mapValue.get(value);
	}
	
	public static HttpRequestType byName(String name){
		return mapName.get(name);
	}
}
